feat: make default workflow domain configurable at runtime#281
feat: make default workflow domain configurable at runtime#281mrsimpson wants to merge 4 commits into
Conversation
Eliminate hardcoded 'code' defaults in WorkflowManager through: - Four-level env var chain: constructor param > WORKFLOW_DOMAINS > DEFAULT_DOMAINS > VIBE_WORKFLOW_DOMAINS > empty Set (all workflows) - defaultDomains constructor parameter for programmatic override - DEFAULT_ALL_DOMAINS env var for getAllAvailableWorkflows() - setDomains() method for runtime domain switching with validation - DOMAIN_DESCRIPTIONS constant with meaningful domain summaries - load_workflows tool in MCP server and OpenCode plugin for LLM to dynamically load domains without restarting the process Fix pre-existing bug: loadPredefinedWorkflows() now clears maps before reloading, preventing workflow accumulation across domain switches. Add 18 new tests: 9 for env var precedence chain, 9 for setDomains(). Update existing domain filtering test for new empty Set default.
Simplify load_workflows tool parameter to use domain name enums instead of embedding full descriptions. This keeps the tool schema lean and reduces LLM context usage. - load_workflows(domains: string[]) now uses a simple enum - New domain-info:// resource exposes full domain descriptions - OpenCode plugin uses enum with inline domain list in description - Domain descriptions kept in DOMAIN_DESCRIPTIONS constant (core)
|
@claude Review once |
PR ReviewGreat overall design — the four-level precedence chain, 🔴 Must fix: Default fallback should remain
|
- Restore 'code' as default fallback in parseEnabledDomains() (was
accidentally changed to empty Set which loads all domains)
- Remove dead getActiveWorkflow() guard — always returned null,
replaced with clear documentation that conflict detection is not
yet implemented
- Document setDomains('') behavior: empty loads all workflows,
pass 'code' to reset to default
- Use constructor param in getAllAvailableWorkflows() instead of
env var mutation — safe for concurrent use
- Export KNOWN_DOMAIN_NAMES from core — single source of truth for
domain names, imported by MCP server and OpenCode plugin
- Revert tests to assert 'code'-only default
This also fixes the CI failure: game-beginner.yaml validation test
now passes because 'children' domain no longer loads by default.
Summary
Eliminate hardcoded
'code'default domain inWorkflowManagerand provide runtime domain switching for long-lived processes (MCP server, OpenCode plugin).Changes
WORKFLOW_DOMAINS>DEFAULT_DOMAINS>VIBE_WORKFLOW_DOMAINS>code(default)defaultDomainsconstructor parameter for programmatic override (library consumers, testing)DEFAULT_ALL_DOMAINSenv var forgetAllAvailableWorkflows()— replaces incomplete hardcoded listsetDomains()method for runtime domain switching with validation against known domainsDOMAIN_DESCRIPTIONSconstant with meaningful summaries of what each domain is suitable forKNOWN_DOMAIN_NAMESconstant — single source of truth for domain names, exported from coreload_workflowstool — simple enum parameter, domain descriptions exposed viadomain://resourcedomain://resource — exposes all available domains with descriptions for LLM discoveryloadPredefinedWorkflows()now clears maps before reloading (prevents workflow accumulation)Tests
setDomains()game-beginner.yamltest now passes)Architecture Decision
Domain descriptions are exposed as a resource (
domain://) rather than embedded in the tool parameter. This keeps the tool schema lean and reduces LLM context usage. The LLM can query the resource to discover domains before callingload_workflows.Affected Files
packages/core/src/workflow-manager.ts— core changespackages/core/test/unit/workflow-domains-precedence.test.ts— 9 new testspackages/core/test/unit/workflow-domain-switching.test.ts— 9 new tests (new file)packages/core/test/unit/workflow-domain-filtering.test.ts— updated forcode-only defaultpackages/mcp-server/src/server-config.ts— registerload_workflowstool +domain://resourcepackages/mcp-server/src/tool-handlers/load-workflows.ts— simplified handler (new file)packages/mcp-server/src/tool-handlers/index.ts— register handlerpackages/opencode-plugin/src/plugin.ts— registerload_workflowstoolpackages/opencode-plugin/src/tool-handlers/load-workflows.ts— simplified handler (new file)Backward Compatibility
VIBE_WORKFLOW_DOMAINSstill works as lowest-priority env varoptions?: WorkflowManagerOptionsto constructor is backward compatiblecode— out-of-the-box behavior unchanged